const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');

const accountRouter = express.Router();

// parse application/x-www-form-urlencoded
accountRouter.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
accountRouter.use(bodyParser.json())

//导入账号控制器模块 
const registControl = require(path.join(__dirname,'../control/accountControl.js'));
//获取注册页面
accountRouter.get('/regist',(req,res)=>{
    registControl.getRegistPage(req,res);
});
//处理注册请求
accountRouter.post('/regist',(req,res)=>{
    registControl.getRegistInfo(req,res);
});
//获取登录页面
accountRouter.get('/login',(req,res)=>{
    registControl.getLoginPage(req,res);
});
//获取验证码
accountRouter.get('/vcode',(req,res)=>{
    registControl.getVcode(req,res);
})
//处理登录请求
accountRouter.post('/login',(req,res)=>{
    registControl.getLoginInfo(req,res);
});

//处理退出请求
accountRouter.get('/logout',registControl.Logout)

module.exports = accountRouter;